// Polyfills for older Node.js versions
// This file provides compatibility for Node.js versions that don't support certain Web APIs

// Headers polyfill for Node.js < 18
if (typeof globalThis.Headers === 'undefined') {
    const { Headers } = require('node-fetch');
    globalThis.Headers = Headers;
}

// Request polyfill for Node.js < 18
if (typeof globalThis.Request === 'undefined') {
    const { Request } = require('node-fetch');
    globalThis.Request = Request;
}

// Response polyfill for Node.js < 18
if (typeof globalThis.Response === 'undefined') {
    const { Response } = require('node-fetch');
    globalThis.Response = Response;
}

// fetch polyfill for Node.js < 18
if (typeof globalThis.fetch === 'undefined') {
    const fetch = require('node-fetch');
    globalThis.fetch = fetch;
}

module.exports = {
    Headers: globalThis.Headers,
    Request: globalThis.Request,
    Response: globalThis.Response,
    fetch: globalThis.fetch
};
